import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'Index',
      component: () => import('../views/Index.vue')
    },
    {
      path:'/layout',
      name:'Layout',
      component: () => import('../views/user/LayoutPage.vue'),
      redirect: '/layout/news',  // Default redirect to HomePage
      children: [
        {
          path: '/layout/home',
          name: 'Home',
          component: () => import('../views/user/HomePage.vue')
        },
        {
          path: '/layout/news',
          name: 'News',
          component: () => import('../views/user/NewsPage.vue')
        },
        {
          path: '/layout/data',
          name: 'Data',
          component: () => import('../views/user/DataCentersPage.vue')
        },
        {
          path: '/layout/barter',
          name: 'Barter',
          component: () => import('../views/user/BarterPage.vue')
        },
        {
          path: '/layout/second',
          name: 'lSecond',
          component: () => import('../views/user/SecondTradingPage.vue')
        },
        {
          path: '/layout/green',
          name: 'Green',
          component: () => import('../views/user/GreenProductPage.vue')
        },
        {
          path: '/layout/carbon',
          name: 'Carbon',
          component: () => import('../views/user/CarbonFootprintPage.vue')
        },
        {
          path: '/layout/volunteer',
          name: 'Volunteer',
          component: () => import('../views/user/VolunteeringPage.vue')
        },
        {
          path: '/layout/my',
          name: 'My',
          component: () => import('../views/user/MyPage.vue')
        },
        {
          path:'/layout/message',
          name: 'Message',
          component: () => import('../views/user/MessagePage.vue')
        },
        {
          path:'/layout/cart',
          name: 'Cart',
          component: () => import('../views/user/CartPage.vue')

        }
      ]
    },
    {
      path: '/product',
      name: 'Product',
      component: () => import('../views/user/GoodsDetailPage.vue')
    },
    {
      path:'/chat',
      name:'Chat',
      component: () => import('../views/user/ChatPage.vue')
    },
    {
      path:'/exchange',
      name:'Exchange',
      component: () => import('../views/user/ExchangePage.vue')
    },
    {
      path:'/myInfo',
      name:'MyInfo',
      component: () => import('../views/MyInfoPage/MyInfoLayout.vue'),
      redirect: '/myInfo/exchangeOrder',
      children:[
        {
          path:'/myInfo/exchangeOrder',
          name:'ExchangeOrder',
          component: () => import('../views/MyInfoPage/ExchangeOrderPage.vue')
        },
        {
          path:'/myInfo/purchaseOrder',
          name:'MyInfoPurchaseOrder',
          component: () => import('../views/MyInfoPage/PurchaseOrderPage.vue')
        },
        {
          path:'/myInfo/collections',
          name:'MyInfoCollections',
          component: () => import('../views/MyInfoPage/CollectionPage.vue')
        },{
           path:'/myInfo/honor',
           name:'Honor',
           component: () => import('../views/MyInfoPage/HonorPage.vue')
        },
        {
          path:'/myInfo/edit-info'
          ,name:'EditInfo',
          component: () => import('../views/MyInfoPage/EditInfoPage.vue')
        },
        {
          path:'/myInfo/points',
          name:'Points',
          component: () => import('../views/MyInfoPage/PointPage.vue')
        },
        {
          path:'/myInfo/publish-product',
          name:'PublishProduct',
          component: () => import('../views/MyInfoPage/PublishPage.vue')

        },
        {
          path:'/myInfo/goodsManage',
          name:'GoodsManage',
          component: () => import('../views/MyInfoPage/GoodsManagePage.vue')
        }


      ]
    },
    {
      path:'/buy',
      name:'Buy',
      component: () => import('../views/user/BuyPage.vue'),
    }

  ]
})

export default router
